/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dischargesimulation.physics;

/**
 *
 * @author rybakov
 */
public class Particles {
    public double[] x;
    public double[] y;
    public double[] z;
    public long max_particle=0;
    
    enum ParticleType{ NONE, ELECTRON, POSITIVEION, NEGATIVEION}
    ParticleType [] particleType;
    
    long getCapacity(){
        if(x==null){
            return 0;
        }else{
            return x.length;
        }
    }
    
    void addCapacity(int n){
        if(x==null){
                x=new double[n];
                y=new double[n];
                z=new double[n];
                particleType=new ParticleType[n];
                return ;
        }else{
            double []old = x;
            x=new double[old.length+n];
            System.arraycopy(old,0,x,0,old.length);
            
            old = y;
            y=new double[old.length+n];
            System.arraycopy(old,0,y,0,old.length);
            
            old = z;
            z=new double[old.length+n];
            System.arraycopy(old,0,z,0,old.length);
            
            ParticleType[] old_pt = particleType;
            particleType=new ParticleType[old.length+n];
            System.arraycopy(old_pt,0,particleType,0,old_pt.length);
            
        }
    }
    
    public static void main(String[]args)throws Exception{
        Particles p = new Particles();
        p.addCapacity(10);
        p.x[1]=1111;
        
        for(int i = 1 ;i<=100; i++){
        p.addCapacity(100000);
        }
        System.out.println(p.x[1]);
        System.out.println(p.x.length);
        
        
    }
    
}
